﻿<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true"
    CodeFile="ViewCarMake.aspx.cs" Inherits="Admin_car_insurance_ViewCarMake" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <div class="contents">
        <table width="100%" cellpadding="3" cellspacing="0" border="0">
            <tr>
                <td colspan="2">
                    <h1>View Car Make</h1>
                </td>
            </tr>
            <tr>
                <td>
                    Car Make : 
                    <asp:TextBox ID="txtSearchCarMake" runat="server"></asp:TextBox> 
                    <asp:Button ID="btnSearchCarMake" runat="server" Text="Search" OnClick="btnSearchCarMake_Click" />
                </td>
                <td width="30%" align="right" style="text-align:right;">
                    <asp:Button ID="btnCreatNewCarMake" runat="server" Text="Create New Car Make" 
                        onclick="btnCreatNewCarMake_Click"  />
                </td>
            </tr>
             <tr>
                <td colspan="2">
                    <asp:GridView ID="grvCarMake" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" Cellspacing="3" CellPadding="3" Width="100%" DataKeyNames="CarMakeId" DataSourceID="sqlDsCarMake"
                        EmptyDataText="There are no data records to display." CssClass="admin_gridstyle" PagerStyle-CssClass="pgr" 
                        GridLines="None" onselectedindexchanged="grvCarMake_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="CarMakeAutoId" HeaderText="CarMakeAutoId" InsertVisible="False"
                                ReadOnly="True" SortExpression="CarMakeAutoId" Visible="False" />
                            <asp:BoundField DataField="CarMakeId" HeaderText="CarMakeId" ReadOnly="True" SortExpression="CarMakeId" />
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                            <asp:CheckBoxField DataField="Status" HeaderText="Status" SortExpression="Status" />
                            <asp:CommandField ShowSelectButton="True" SelectText="Edit" />
                            <asp:BoundField DataField="RefCEUserId" HeaderText="RefCEUserId" SortExpression="RefCEUserId"
                                Visible="False" />
                            <asp:BoundField DataField="CreatedDate" HeaderText="CreatedDate" SortExpression="CreatedDate"
                                Visible="False" />
                            <asp:BoundField DataField="ModifiedDate" HeaderText="ModifiedDate" SortExpression="ModifiedDate"
                                Visible="False" />
                        </Columns>
                        <FooterStyle />
                        <PagerStyle />
                        <SelectedRowStyle />
                        <HeaderStyle CssClass="admin_gridheader" />
                        <EditRowStyle />
                        <AlternatingRowStyle CssClass="admin_gridodd" />
                        <RowStyle CssClass="admin_grideven" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="sqlDsCarMake" runat="server" ConnectionString="<%$ ConnectionStrings:TH.CX_DBConnectionString %>"
                        
                        
                        DeleteCommand="DELETE FROM [tblCarMakeInfo] WHERE [CarAutoId] = @CarAutoId" InsertCommand="INSERT INTO [tblCarMakeInfo] ([CarMakeId], [Description], [Status], [RefCEUserId], [CreatedDate], [Modified]) VALUES (@CarMakeId, @Description, @Status, @RefCEUserId, @CreatedDate, @Modified)"
                        ProviderName="<%$ ConnectionStrings:TH.CX_DBConnectionString.ProviderName %>" SelectCommand="SELECT [CarMakeAutoId], [CarMakeId], [Description], [Status], [RefCEUserId], [CreatedDate], [ModifiedDate] FROM [tblCarMakeInfo] Where [Description] Like '%' + isnull(@Description,'%') + '%' Order By [Description]"
                        
                        
                        UpdateCommand="UPDATE [tblCarMakeInfo] SET [CarMakeId] = @CarMakeId, [Description] = @Description, [Status] = @Status, [RefCEUserId] = @RefCEUserId, [CreatedDate] = @CreatedDate, [Modified] = @Modified WHERE [CarAutoId] = @CarAutoId">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtSearchCarMake" ConvertEmptyStringToNull="False"
                                 DefaultValue="%" Name="Description" PropertyName="Text" />
                        </SelectParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="CarAutoId" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                            <asp:Parameter Name="CreatedDate" Type="DateTime" />
                            <asp:Parameter Name="Modified" Type="DateTime" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="CarMakeId" Type="Int32" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="Status" Type="Boolean" />
                            <asp:Parameter Name="RefCEUserId" Type="Int64" />
                            <asp:Parameter Name="CreatedDate" Type="DateTime" />
                            <asp:Parameter Name="Modified" Type="DateTime" />
                            <asp:Parameter Name="CarAutoId" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
